#!/bin/bash

# Copyright (c) 2021 iSoftStone Open Source Organization .
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# ${1}  /home/toutes/X3588s_openharmony/ohos/out/yangfan/packages/phone/images
# ${2}  /home/toutes/X3588s_openharmony/ohos/device/board/isoftstone/yangfan
# ${3}  ../../kernel/linux/linux-5.10

set -e

ROOT_DIR=${1}

UBOOT_SOURCE=${ROOT_DIR}/device/board/opintelink/uboot/x3588s_bootloader
UBOOT_SRC_TMP_PATH=${ROOT_DIR}/out/uboot/src_tmp/x3588s_bootloader
FLASH_CONFIG=${ROOT_DIR}/device/board/opintelink/intelink_rk3588s/config

rm -rf ${UBOOT_SRC_TMP_PATH}
mkdir -p ${UBOOT_SRC_TMP_PATH}

cp -arf ${UBOOT_SOURCE}/* ${UBOOT_SRC_TMP_PATH}/

cd ${UBOOT_SRC_TMP_PATH}

./make.sh rk3588-edge

mkdir -p ${2}

cp ${UBOOT_SRC_TMP_PATH}/rk3588_spl_loader_v1.07.111.bin ${2}/MiniLoaderAll.bin
cp ${UBOOT_SRC_TMP_PATH}/uboot.img ${2}/uboot.img
cp ${FLASH_CONFIG}/config.cfg ${2}/config.cfg
cp ${FLASH_CONFIG}/parameter.txt ${2}/parameter.txt

#popd
